﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MDT_Metro_monitoring.ComputersTitles"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MDT_Metro_monitoring"
    xmlns:data="using:MDT_Metro_monitoring.Data"
    xmlns:common="using:MDT_Metro_monitoring.Common"
    xmlns:mdt="using:MDT_MonitorModel"
    xmlns:col="using:System.Collections.ObjectModel"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="serverSource"
            IsSourceGrouped="True" />
        <CollectionViewSource
            x:Name="computerSource"
            IsSourceGrouped="True"/>
        <CollectionViewSource
            x:Name="groupedComputerSource"
            IsSourceGrouped="False"/>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource MDTRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <local:ServerManagementSettings
                    x:Name="ServerSettings"
                    HorizontalAlignment="Right"
                    Margin="0,0,-736,0" Grid.RowSpan="2" >
            <UserControl.Transitions>
                <TransitionCollection>
                    <RepositionThemeTransition/>
                </TransitionCollection>
            </UserControl.Transitions>
        </local:ServerManagementSettings>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" Style="{StaticResource PageHeaderTextStyle}"/>
            <Button Content="Button" Grid.Column="1" HorizontalAlignment="Left" Margin="831,79,0,0" VerticalAlignment="Top" Click="Button_Click_1"/>
        </Grid>

        <!-- Horizontal scrolling grid used in most view states -->
        <GridView x:Name="ServersGridView"
                    AutomationProperties.AutomationId="ServersGridView"
                    Margin="0,0,0,0"
                    Padding="116,0,40,46"
                    Grid.Row="1"
                    ItemsSource="{Binding Source={StaticResource serverSource}}"
                    ItemTemplate="{StaticResource ServerItemTemplate}"
                    IsItemClickEnabled="True"          
                    ItemClick="Item_click"
                    SelectionMode="None">

            <GridView.Header>
                <StackPanel Width="310" Margin="0,4,14,0">
                    <TextBlock HorizontalAlignment="Left" Margin="0,0,18,20" TextWrapping="Wrap" Text="Overview" VerticalAlignment="Top" Style="{StaticResource SubheaderTextStyle}"/>

                    <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" Text="Servers Status" VerticalAlignment="Top" FontSize="24" Style="{StaticResource BodyTextStyle}"/>
                    <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
                            <Run Text="Nb Servers:"/>
                            <Run x:Name="NbServer"/>
                    </TextBlock>

                    <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
                            <Run Text="Offline Servers:"/>
                            <Run x:Name="NbServerOffline"/>
                    </TextBlock>

                    <TextBlock HorizontalAlignment="Left" Margin="0,70,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="24" Style="{StaticResource BodyTextStyle}">
            	<Run Text="Clients Status"/>
                    </TextBlock>
                    <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
            	<Run Text="Client in error:"/>
                <Run x:Name="NbClientError"/>
                    </TextBlock>
                    <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
            	<Run Text="Client in Warning:"/>
                <Run x:Name="NbClientWarning"/>
                    </TextBlock>
                    <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Style="{StaticResource BasicTextStyle}">
                        <Run Text="Installation completion:" />
                        <Run x:Name="InstallationCompletion"/>
                    </TextBlock>
                </StackPanel>
            </GridView.Header>
            <GridView.ItemContainerStyle>
                <Style TargetType="FrameworkElement">
                    <Setter Property="Margin" Value="0,0,10,10"/>
                </Style>
            </GridView.ItemContainerStyle>
            <GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>

            <GridView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="0,11,0,6">
                                <Button
                                            AutomationProperties.Name="Group Title"
                                            Content="{Binding Key}"
                                            Style="{StaticResource TextButtonStyle}"
                                            Click="ServerTitle_click"/>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </GridView.GroupStyle>

        </GridView>

        <!-- Horizontal scrolling grid used in most view states -->
        <GridView x:Name="ServersGridViewPortrait"
                    AutomationProperties.AutomationId="ServersGridView"
                    Margin="0,0,0,0"
                    Padding="96,0,10,56"
                    Grid.Row="1"
                    ItemsSource="{Binding Source={StaticResource serverSource}}"
                    ItemTemplate="{StaticResource ServerItemTemplate}"
                    IsItemClickEnabled="True"          
                    ItemClick="Item_click"
                    SelectionMode="None">

            <GridView.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Width="310" Margin="0,4,14,0" Grid.Column="0">
                        <TextBlock HorizontalAlignment="Left" Margin="0,0,18,20" TextWrapping="Wrap" Text="Overview" VerticalAlignment="Top" Style="{StaticResource SubheaderTextStyle}"/>

                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" Text="Servers Status" VerticalAlignment="Top" FontSize="24" Style="{StaticResource BodyTextStyle}"/>
                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
                            <Run Text="Nb Servers:"/>
                            <Run x:Name="NbServerPortrait"/>
                        </TextBlock>

                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
                            <Run Text="Offline Servers:"/>
                            <Run x:Name="NbServerOfflinePortrait"/>
                        </TextBlock>
                    </StackPanel>
                    <StackPanel Width="310" Margin="0,4,14,0" Grid.Column="1">
                        <TextBlock HorizontalAlignment="Left" Margin="0,0,18,20" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Style="{StaticResource SubheaderTextStyle}"/>
                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="24" Style="{StaticResource BodyTextStyle}">
            	<Run Text="Clients Status"/>
                        </TextBlock>
                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
            	<Run Text="Client in error:"/>
                <Run x:Name="NbClientErrorPortrait"/>
                        </TextBlock>
                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
            	<Run Text="Client in Warning:"/>
                <Run x:Name="NbClientWarningPortrait"/>
                        </TextBlock>
                        <TextBlock HorizontalAlignment="Left" Margin="0,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Style="{StaticResource BasicTextStyle}">
                        <Run Text="Installation completion:" />
                        <Run x:Name="InstallationCompletionPortrait"/>
                        </TextBlock>
                    </StackPanel>
                </Grid>
            </GridView.Header>
            <GridView.ItemContainerStyle>
                <Style TargetType="FrameworkElement">
                    <Setter Property="Margin" Value="0,0,10,10"/>
                </Style>
            </GridView.ItemContainerStyle>
            <GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>

            <GridView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="0,11,0,6">
                                <Button
                                            AutomationProperties.Name="Group Title"
                                            Content="{Binding Key}"
                                            Style="{StaticResource TextButtonStyle}"
                                            Click="ServerTitle_click"/>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.Panel>
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid Orientation="Horizontal" Margin="0,0,80,0"/>
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>
                </GroupStyle>
            </GridView.GroupStyle>

        </GridView>

        <!-- Vertical scrolling list only used when snapped -->
        <ListView x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,-10,0,0"
            Padding="10,0,0,60">

            <ListView.Header>
                <StackPanel Width="310" Margin="0,4,14,0">
                    <TextBlock HorizontalAlignment="Left" Margin="0,0,18,20" TextWrapping="Wrap" Text="Overview" VerticalAlignment="Top" Style="{StaticResource SubheaderTextStyle}"/>

                    
                    <Button HorizontalAlignment="Left" Margin="39,10,0,0" Content="Servers Status" VerticalAlignment="Top" FontSize="24"  Style="{StaticResource MDTButton}" Click="Overview_Server"/>
                    <TextBlock HorizontalAlignment="Left" Margin="39,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
                            <Run Text="Nb Servers:"/>
                            <Run x:Name="NbServerSnapped"/>
                    </TextBlock>

                    <TextBlock HorizontalAlignment="Left" Margin="39,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
                            <Run Text="Offline Servers:"/>
                            <Run x:Name="NbServerOfflineSnapped"/>
                    </TextBlock>

                    <Button HorizontalAlignment="Left" Margin="39,70,0,0" Content="Clients Status" VerticalAlignment="Top" FontSize="24" Style="{StaticResource MDTButton}" Click="Overview_Client"/>

                    <TextBlock HorizontalAlignment="Left" Margin="39,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
            	<Run Text="Client in error:"/>
                <Run x:Name="NbClientErrorSnapped"/>
                    </TextBlock>
                    <TextBlock HorizontalAlignment="Left" Margin="39,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Width="165" Style="{StaticResource BasicTextStyle}">
            	<Run Text="Client in Warning:"/>
                <Run x:Name="NbClientWarningSnapped"/>
                    </TextBlock>
                    <TextBlock HorizontalAlignment="Left" Margin="39,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="16" Style="{StaticResource BasicTextStyle}">
                        <Run Text="Installation completion:" />
                        <Run x:Name="InstallationCompletionSnapped"/>
                    </TextBlock>
                </StackPanel>
            </ListView.Header>
        </ListView>
        
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ServersGridViewPortrait" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait. Also changing the way of displaying items -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ServersGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list is removed
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ServersGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ServersGridViewPortrait" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>


</common:LayoutAwarePage>
